from typing import List


class Solution:
    def sumOddLengthSubarrays(self, arr: List[int]) -> int:
        arr1 = [0] * len(arr)
        arr1[0] = arr[0]
        for i in range(1, len(arr)):
            arr1[i] = arr[i] + arr1[i - 1]
        ans = 0
        for i in range(1, len(arr)+1, 2):
            ans += i * arr1[-1]

            for j in range(1,i):

                ans-=(i-j)*(arr[j-1]+arr[-j])
        return ans


if __name__ == '__main__':
    s = Solution()
    arr = [1, 4, 2, 5, 3]
    s.sumOddLengthSubarrays(arr)
    # print(arr[-0])
